home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr30 / clsh.zip / CLSH.ASM next >
Assembly Source File  |  1993-05-04  |  6KB  |  237 lines

  1. ; Clear Screen and Hold
  2. ; By Matthew J. W. Ratcliff
  3. ; Ratware Softworks
  4. ; PUBLICWARE
  5. ; Distribute this code FREEly
  6. ;
  7. ; Clear the screen and hold until a key is pressed.
  8. ; The text display is switched from screen 0 to screen 1.
  9. ; A '#' character is printed at random positions on the
  10. ; display once every two seconds - just to let you know
  11. ; the computer is on.  (A completely blank screen might fake
  12. ; you out and cause you to power cycle the computer.)
  13. ; When any key is pressed, the display is switched back to
  14. ; screen 0 - with the information originally there intact.
  15. ; This can be called from the dos command line or shell
  16. ; from any other program capable of executing DOS commands.
  17. ; Use this utility to clear the screen and prevent
  18. ; phosphor burn.  Why WASTE memory on another TSR when
  19. ; you don't have to?  Use CLSH!  A petite 1280 byte .EXE file
  20. ; written with MASM 4.0
  21.  
  22. ; I originally wrote this with Microsoft C 5.1.  Although the
  23. ; C source code was under 1300 bytes, the executable was over 18k!
  24. ; With the help of The NEW Peter Norton "Programmer's Guide to the
  25. ; IBM PC & PS/2" I was able to rewrite CLSH as a stand alone
  26. ; assembly language program.  The source file is about 5K, and the
  27. ; executable only 1280 bytes.  There are times when it PAYS to use
  28. ; assembly language!            Mat*Rat  PPN: 76703,1077
  29.  
  30.  
  31.         PAGE    ,132  ; (CTRL-OH)   IBM PC PRINTER CONDENSED MODE
  32.     TITLE    SKELEXE2 - SAMPLE.EXE STYLE WITH DOS 2.0+ EXIT INTERFACE
  33. DSEG    SEGMENT PARA PUBLIC 'DATA'
  34.  
  35.  
  36. ;insert data here
  37.  
  38. TIME18 DW 0
  39. DELAY  DB 0, 0
  40. BLIPX  DB 0
  41. BLIPY  DB 0
  42. SPACE  DB ' $'
  43. PERIOD DB '#$'
  44. MYNAME DB 'Clear Screen and Hold, by Mat*Rat$'
  45.  
  46. DSEG    ENDS
  47.  
  48. CSEG    SEGMENT PARA PUBLIC 'CODE'
  49.     ASSUME    CS:CSEG,SS:STACK    ;ALREADY SET BY DOS LOADER
  50.  
  51. ;insert constants here
  52.  
  53. ONESECOND EQU 18
  54. NORMSCR   EQU 0
  55. CLRSCR    EQU 1
  56.  
  57.  
  58. ENTPT   PROC    FAR                     ;ENTRY POINT FROM DOS
  59.     MOV    AX,DSEG         ;SET UP ADDRESSABILITY TO
  60.     MOV    DS,AX            ; THE DATA SEGMENT
  61.     ASSUME    DS:DSEG         ;TELL ASSEMBLER WHAT I JUST DID
  62.  
  63. ;insert code here
  64.  
  65. ; Select Text Screen #1
  66.  
  67.         CALL ENACLR
  68.  
  69. ; Get current time
  70.  
  71.         MOV AH,00H
  72.         INT 1AH
  73.         MOV TIME18,DX
  74.  
  75. ; Iniz RANDOM X & Y
  76.  
  77.         CALL GETNEWXY
  78.  
  79. ; Now clear the display
  80.  
  81.         MOV AH,06H                      ; Scroll function
  82.         MOV AL,24                       ; Scroll 25 lines
  83.         MOV BH,0                        ; fill attribute
  84.         MOV CX,0000H                    ; Upper row:left column
  85.         MOV DX,256*24+79                ; Lower row:right column
  86.         INT 10H                         ; Video interrupt service
  87.  
  88. ; Now wait for a keypress to exit
  89.  
  90. KEYWAIT:
  91.         MOV AH,01H                      ; Keyboard status
  92.         INT 16H                         ; Keyboard interrupt service
  93.         JNE  KEYEXIT                     ; Not zero, wait
  94.  
  95.         MOV AH,00
  96.         INT 1AH
  97.         MOV CX,DX
  98.         SUB DX,TIME18
  99.         CMP DX,ONESECOND
  100.         JL  KEYWAIT
  101.         MOV TIME18,CX
  102.  
  103. DOBLIP:
  104.         INC DELAY                       ; Blip on or off?
  105.         MOV AL,DELAY
  106.         AND AL,01H
  107.         CMP AL,0
  108.         JE  BLIPON
  109.  
  110. BLIPOFF:
  111.         CALL EBLIP
  112.         CALL GETNEWXY
  113.         JMP SHORT KEYWAIT
  114.  
  115. BLIPON:
  116.         CALL SBLIP
  117.         JMP SHORT KEYWAIT
  118.  
  119.  
  120. ; Now fetch the keypress and exit
  121. KEYEXIT:
  122.         MOV AH,00H                      ; Keyboard read
  123.         INT 16H                         ; Keyboard interrupt service
  124.  
  125. ; Now switch back to screen 0
  126.         CALL ENANORM
  127.         MOV DX,OFFSET MYNAME
  128.         CALL WRITE
  129.  
  130. RET_CD  EQU     0                       ;ERRORLEVEL RETURN CODE VALUE
  131. RET_FN    EQU    4CH            ;"RETURN TO DOS" FUNCTION CALL
  132.  
  133.     MOV    AX,RET_FN*256 + RET_CD    ;RETURN TO DOS FUNCTION CALL, AND
  134.                     ;VALUE TO BE PASSED TO ERRORLEVEL
  135.     INT    21H            ;RETURN TO DOS
  136.                     ; (VERSION 2.00 OR LATER)
  137. ENTPT    ENDP
  138.  
  139.  
  140. ; EBLIP - Print a space character at the current BLIPX, BLIPY
  141.  
  142. EBLIP   PROC    NEAR
  143.         CALL SETPOS
  144.         MOV DX,OFFSET SPACE
  145.         CALL WRITE
  146.         RET
  147. EBLIP   ENDP
  148.  
  149. ; SBLIP - Print a '.' character at the new BLIPX, BLIPY
  150.  
  151. SBLIP   PROC    NEAR
  152.         CALL SETPOS
  153.         MOV DX, OFFSET PERIOD
  154.         CALL WRITE
  155.         RET
  156. SBLIP   ENDP
  157.  
  158. ; SETXY - Take AX and put valid X and Y values in BLIPX, BLIPY
  159.  
  160. SETXY   PROC    NEAR
  161.  
  162.         AND AH,1FH                      ; Generate random Y
  163.         CMP AH,23                       ; Greater than 23?
  164.         JL  SETXY1
  165.         MOV AH,22
  166. SETXY1:
  167.         MOV BLIPY,AH
  168.  
  169.         AND AL,7FH                      ; Generate random X
  170.         CMP AL,80                       ; Greater than 79?
  171.         JL  SETXY2
  172.         MOV AL,79
  173. SETXY2:
  174.         MOV BLIPX,AL
  175.         RET
  176.  
  177. SETXY   ENDP
  178.  
  179. ; SETPOS - Take BLIPX, BLIPY and set cursor position
  180.  
  181. SETPOS  PROC    NEAR
  182.         MOV BH,CLRSCR                   ; Page number 1
  183.         MOV AH,02H                      ; Set cursor pos. function
  184.         MOV DH,BLIPY
  185.         MOV DL,BLIPX
  186.         INT 10H                         ; Video interrupt service
  187.         RET
  188. SETPOS  ENDP
  189.  
  190. ; GETNEWXY - Read time and use 18.2HZ count value as random X,Y
  191.  
  192. GETNEWXY PROC NEAR
  193.         MOV AH,00                       ; Read clock counter
  194.         INT 1AH                         ; Read clock interrupt service
  195.         MOV AX,DX
  196.         OR  DL,DH
  197.         XOR AH,DL
  198.         CALL SETXY
  199.         RET
  200. GETNEWXY ENDP
  201.  
  202. ; WRITE - Send the character in AL to the video display
  203.  
  204. WRITE   PROC    NEAR
  205.  
  206.         MOV AH,09H
  207.         INT 21H
  208.         RET
  209.  
  210. WRITE   ENDP
  211.  
  212. ; ENACLR - Enable the clear and hold screen
  213.  
  214. ENACLR  PROC    NEAR
  215.         MOV AH,05H
  216.         MOV AL,CLRSCR
  217.         INT 10H
  218.         RET
  219. ENACLR  ENDP
  220.  
  221. ; ENANORM - Enable the normal screen
  222.  
  223. ENANORM PROC    NEAR
  224.         MOV AH,05H
  225.         MOV AL,NORMSCR
  226.         INT 10H
  227.         RET
  228. ENANORM ENDP
  229.  
  230.  
  231. CSEG    ENDS
  232.  
  233. STACK    SEGMENT PARA STACK 'STACK'
  234.     DB    64 DUP("STACK   ")      ;256 WORD STACK AREA
  235. STACK    ENDS
  236.     END    ENTPT
  237.